package prawnBot;

import lejos.nxt.Sound;

/**
 * This class contains a set of various static sound methods.
 * They are useful debugging tools when inserted at code breakpoints.
 * 
 * @author Stephane Beniak - 260324952
 */
public class Beeper {
   
   private static final int A = 1760;
   private static final int C = 2093;
   private static final int Db = 2217;
   private static final int E = 2637;
   
   private static int TIME = 200;
   private static int PAUSE = 50;
   
   /**
    * Sounds a single beep (A6) 
    */
   public static void one(){
      sound(A, TIME, PAUSE);
   }
   
   /**
    * Sounds a double beep (A6) 
    */
   public static void two(){
      sound(A, TIME, PAUSE);
      sound(A, TIME, PAUSE);
   }
   
   /**
    * Sounds a single short beep (A5) 
    */
   public static void shorty(){
      sound(A/2, TIME/2, PAUSE/2);
   }
   
   /**
    * Sounds a low "bad" beep (C4)
    */
   public static void low(){
      sound(C/4, TIME, PAUSE);
      sound(A/4, TIME, PAUSE);
   }
   
   /**
    * Sounds a minor arpeggio in A (A6) 
    */
   public static void minor(){
      sound(A/2, TIME, PAUSE);
      sound(C/2, TIME, PAUSE);
      sound(E/2, TIME, PAUSE);
      sound(A, TIME, PAUSE);
   }
   
   /**
    * Sounds a major arpeggio in A (A6) 
    */
   public static void major(){
      sound(A/2, TIME, PAUSE);
      sound(Db/2, TIME, PAUSE);
      sound(E/2, TIME, PAUSE);
      sound(A, TIME, PAUSE);
   }
   
   /**
    * Wrapper class for the tedious default playTone() method.
    * 
    * @param pitch The frequency in Hz of the note to be played
    * @param length How long the note will be played, in ms
    * @param pause How long the silence will be after the note, in ms
    */
   public static void sound(int pitch, int length, int pause){
      Sound.playTone(pitch, length);
      try { Thread.sleep(length + pause); } catch (Exception e) {}
   }
   
}